package com.allinpay.mars.common.db.vault.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

/**
 * @author chenzs1
 * @since 2021-12-16
 */
@Slf4j
public class RestTemplateUtils {

    private RestTemplateUtils() {
    }

    private static final RestTemplate restTemplate = new RestTemplate();

    public static <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<T> httpEntity, Class<T> clazz) {
        log.info("exchange data to {}", url);
        return restTemplate.exchange(url, method, httpEntity, clazz);
    }

}
